﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WindowsFormsAsyncUsing.localhost;

namespace WindowsFormsAsyncUsing
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Service1 serv = new Service1();
            this.button1.Text= serv.Foo();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.button2.Text = "test";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Service1 serv = new Service1();
            serv.FooCompleted += new FooCompletedEventHandler(serv_FooCompleted);
            serv.FooAsync();
        }

        void serv_FooCompleted(object sender, FooCompletedEventArgs e)
        {
            //throw new NotImplementedException();
            this.button3.Text= e.Result;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.button4.Text = "test";
        }
    }
}
